<template>
<!-- 	<view class="">
		<image 
		:src="list[src_index].src" 
		mode=""
		@touchstart="start"
		@touchend="end"
		></image>
	</view> -->
	<swiper class="swiper"  interval="3000" circular="true" current="1">
		<swiper-item v-for="(item,index) in list" :key="index">
			<view class="swiper-item uni-bg-red">
				<image :src="item.src" mode=""></image>
			</view>
		</swiper-item>
	</swiper>
</template>

<script>
	export default {
		data () {
			return {
				src_index:0,
				startx:0,
				endX:0,
				length:0,
				list:[
					{src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/client/4.jpg'},
					{src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/client/6.png'},
					{src:'https://ykp-new.oss-cn-hangzhou.aliyuncs.com/client/7.png'}
				]
			}
		},
		onLoad() {
			this.length = this.list.length-1
		},
		methods: {
			// changepic (e) {
			// 	 // console.log (e.target)
			// }
			move (e) {
				 // console.log (e.changedTouches[0].pageX)
			},
			start (e) {
				 // console.log (e.changedTouches[0].pageX)
				this.startx =e.changedTouches[0].pageX
			},
			end (e) {
				 // console.log (e.changedTouches[0].pageX)
				this.endX=e.changedTouches[0].pageX
				if(this.endX - this.startx >50) {
					if (this.src_index == 0) {
						uni.showToast({
							icon:'none',
						    title: '这是第一张',
						    duration: 2000
						});
						return false
					}
					this.src_index--
				}
				if(this.endX - this.startx < -50) {
					if (this.src_index == this.length) {
						uni.showToast({
							icon:'none',
						    title: '这是最后一张',
						    duration: 2000
						});
						return false
					}
					this.src_index++
				}
				
			}
		}
	}
</script>

<style lang="less" scoped>
	.iii {
		width: 100%;
		height: 200upx;
		background-color: pink;
	}
</style>
